# coding:UTF-8
from PIL import Image
import numpy as np

# 加载图像并转换为Numpy数组
im = Image.open('./微信图片_20240918164253.jpg') # 通过绝对路径打开图片位置
im_array = np.array(im)

# 图像翻转
flipped_image = np.flipud(im_array) # 上下翻转
flipped_image1 = np.fliplr(im_array) # 左右翻转

# 图像颜色操作
color_swapped_image = im_array[:,:,::-1] # 交换红色和蓝色通道

# 图像拉伸
new_width = 2 * im.width
new_height = 2 * im.height
resized_image = np.resize(im_array,(new_height,new_width,im_array.shape[2]))
# 指定新的图像尺寸

if __name__ == '__main__':
    # 输出翻转后的图片
    #flipped_im = Image.fromarray(flipped_image)
    flipped_im = Image.fromarray(flipped_image1)
    #flipped_im = Image.fromarray(color_swapped_image)
    #flipped_im = Image.fromarray(resized_image)
    flipped_im.show()
